import redis

# 连接到 Redis 服务器
r = redis.Redis(host="49.4.115.8", port=6379, db=0)

# 字符串类型（6 个）
r.set('str_key1', 'Value for string 1')
r.set('str_key2', 'Value for string 2')
r.set('str_key3', 'Value for string 3')
r.set('str_key4', 'Value for string 4')
r.set('str_key5', 'Value for string 5')
r.set('str_key6', 'Value for string 6')

# 哈希类型（6 个，每个哈希包含 2 个字段）
r.hset('hash_key1', 'field1', 'hash_value1_1')
r.hset('hash_key1', 'field2', 'hash_value1_2')
r.hset('hash_key2', 'field1', 'hash_value2_1')
r.hset('hash_key2', 'field2', 'hash_value2_2')
r.hset('hash_key3', 'field1', 'hash_value3_1')
r.hset('hash_key3', 'field2', 'hash_value3_2')
r.hset('hash_key4', 'field1', 'hash_value4_1')
r.hset('hash_key4', 'field2', 'hash_value4_2')
r.hset('hash_key5', 'field1', 'hash_value5_1')
r.hset('hash_key5', 'field2', 'hash_value5_2')
r.hset('hash_key6', 'field1', 'hash_value6_1')
r.hset('hash_key6', 'field2', 'hash_value6_2')

# 列表类型（6 个，每个列表添加 2 个元素）
r.lpush('list_key1', 'list_element1_1')
r.lpush('list_key1', 'list_element1_2')
r.lpush('list_key2', 'list_element2_1')
r.lpush('list_key2', 'list_element2_2')
r.lpush('list_key3', 'list_element3_1')
r.lpush('list_key3', 'list_element3_2')
r.lpush('list_key4', 'list_element4_1')
r.lpush('list_key4', 'list_element4_2')
r.lpush('list_key5', 'list_element5_1')
r.lpush('list_key5', 'list_element5_2')
r.lpush('list_key6', 'list_element6_1')
r.lpush('list_key6', 'list_element6_2')

# 集合类型（6 个，每个集合添加 2 个成员）
r.sadd('set_key1', 'set_member1_1')
r.sadd('set_key1', 'set_member1_2')
r.sadd('set_key2', 'set_member2_1')
r.sadd('set_key2', 'set_member2_2')
r.sadd('set_key3', 'set_member3_1')
r.sadd('set_key3', 'set_member3_2')
r.sadd('set_key4', 'set_member4_1')
r.sadd('set_key4', 'set_member4_2')
r.sadd('set_key5', 'set_member5_1')
r.sadd('set_key5', 'set_member5_2')
r.sadd('set_key6', 'set_member6_1')
r.sadd('set_key6', 'set_member6_2')

# 有序集合类型（6 个，每个有序集合添加 2 个元素）
r.zadd('zset_key1', {'zset_item1_1': 1, 'zset_item1_2': 2})
r.zadd('zset_key2', {'zset_item2_1': 3, 'zset_item2_2': 4})
r.zadd('zset_key3', {'zset_item3_1': 5, 'zset_item3_2': 6})
r.zadd('zset_key4', {'zset_item4_1': 7, 'zset_item4_2': 8})
r.zadd('zset_key5', {'zset_item5_1': 9, 'zset_item5_2': 10})
r.zadd('zset_key6', {'zset_item6_1': 11, 'zset_item6_2': 12})

print("30 个键值对设置完成。")

# import redis
#
# # 连接到 Redis 服务器
# r = redis.Redis(host="49.4.115.8", port=6379, db=0)
#
# # 以下可以继续添加你的键值对设置代码
# r.set('test_key', 'test_value')
#
# print("键值对设置完成。")


# class Solution:
#     def missingNumber(self, nums: List[int]) -> int:
#         sums = (len(nums) * (len(nums) + 1)) // 2
#         for i in nums:
#             sums -= i
#
#         return sums

# class Solution:
#     def isUnique(self, astr: str) -> bool:
#         char_set = set()
#         for c in astr:
#             if c in char_set:
#                 return False
#             else:
#                 char_set.add(c)
#         return True